#coding:utf-8
from china_addr import *
from random import randint

def randlist(*alist):
    index=randint(0,len(alist)-1)
    return alist[index]
class Address(object):
    def __init__(self,province=None,city=None,town=None,mock=True):        
        if not mock:
            self.province=province
            self.city=city
            self.town=town
        else:
            p=randlist(*PROVINCE)
            index=p[0]
            if index>7 and index != 28:
                c=randlist(*CITY[p[0]])
                t=randlist(*TOWN[c[0]])
            else:
                c,t=((0,""),(0,""))
            self.province=p[1]
            self.city=c[1]
            self.town=t[1]
    def __str__(self):
        return "".join([self.province,self.city,self.town])
if __name__ == "__main__":
    a = Address();
    print a

